package com.tianzheng.rzzl.ui.main

import android.app.Application
import androidx.databinding.ObservableField
import androidx.viewpager.widget.PagerAdapter
import com.basic.library.base.BaseViewModel
import com.basic.library.bean.DataResult
import com.basic.library.binding.command.BindingCommand
import com.basic.library.binding.command.BindingConsumer
import com.basic.library.bus.event.SingleLiveEvent
import com.basic.library.httpmanager.task.RHttpManager
import com.tianzheng.rzzl.R
import com.tianzheng.rzzl.base.ApiConfig

/**
 * 首页
 *
 */
class MainViewModel(application: Application) : BaseViewModel(application) {

    private var radioIds = arrayListOf(R.id.rb_main_message, R.id.rb_main_work, R.id.rb_main_mine)

    var currentItem = ObservableField(0)
    var checkedButtonId = ObservableField(R.id.rb_main_work)
    var adapter = ObservableField<PagerAdapter>()
    val checkEvent = SingleLiveEvent<Boolean>()


    var onCheckedChangeListener: BindingCommand<Int> = BindingCommand(BindingConsumer {
        currentItem.set(radioIds.indexOf(it))
    })

    var onpageSelected: BindingCommand<Int> = BindingCommand(BindingConsumer {
        checkedButtonId.set(radioIds[it])
        checkEvent.postValue(it != 1)
    })

}